<template>
	<view class="app-container">
		<z-paging ref="paging" safe-area-inset-bottom v-model="dataList" @query="queryList">
			<u-navbar slot="top" :title="title" leftIconColor="#fff" :autoBack="true" placeholder bgColor="#cf141a"
				:titleStyle="{ color: '#fff' }">
			</u-navbar>
			<view class="search-item flex flex-between" slot="top">
				<u-search placeholder="房源标题或小区名称" v-model="keyword" animation :clearabled="true" bgColor="#fff"
					:actionStyle="{ color: '#a9a9a9' }" borderColor="#a9a9a9" height="70rpx" @custom="keywordCustom"
					@clear="keywordClear"></u-search>
			</view>
			<view class="goods-list">
				<view class="list-item" v-for="(item, index) in dataList" :key="index"
					@click="$toPath.goPage('pages/listings/details', { id: item.id })">
					<view class="list-info flex">
						<u--image :showLoading="true" :src="item.img" width="246rpx" height="188rpx"></u--image>
						<view class="info">
							<u--text :text="item.title" :lines="2" block color="#000000" size="28rpx"></u--text>
							<view class="label flex">
								<u--text v-if="item.square !== '0'" :text="item.square" block align="left"
									color="#717171" size="28rpx"></u--text>
								<u--text v-if="item.structure !== '0'" :text="item.structure" block align="left"
									color="#717171" size="28rpx"></u--text>
							</view>
							<view class="price-item flex">
								<view class="item flex">
									<u--text text="起拍价" block align="left" color="#6e6e6e" size="24rpx"></u--text>
									<u--text :text="item.start_price" block align="left" color="#cf141a" size="28rpx"
										margin="0 10rpx 0"></u--text>
								</view>
								<view class="item flex">
									<u--text text="评估价" block align="left" color="#6e6e6e" size="24rpx"></u--text>
									<u--text :text="item.evaluate_price" block align="left" color="#cf141a" size="28rpx"
										margin="0 10rpx 0"></u--text>
								</view>
							</view>
						</view>
					</view>
					<view class="list-mode flex flex-between flex-align-center">
						<view class="count-item flex">
							<block v-if="item.status === '1' || item.status === '0'">
								<u--text :text="item.status === '0' ? '开拍时间：' : '结束时间：'" block align="left"
									color="#606060" size="26rpx"></u--text>
								<liu-countdown ref="countdown" :showSeconds="true" mode="2"
									:endDate="item.countdown_time" :auto="true"></liu-countdown>
							</block>
						</view>
						<view class="status flex flex-align-center flex-justify-center"
							:class="item.status === '1' ? 'error' : item.status === '0' ? 'succeed' : 'finish'">
							{{ item.status === '1' ? '正在拍卖' : item.status === '0' ? '即将开拍' : '拍卖结束' }}
						</view>
					</view>
				</view>
			</view>
		</z-paging>
		<w-picker :visible.sync="pop.time.visible" mode="range" startYear="1970" endYear="2999" themeColor="#cf141a"
			@confirm="onConfirm($event, 'range')" @cancel="onCancel" ref="range"></w-picker>
	</view>
</template>

<script>
	import wPicker from '@/components/w-picker/w-picker.vue';
	export default {
		components: {
			wPicker
		},
		data() {
			return {
				keyword: '',
				dataList: [],
				type: '',
				status: '',
				title: '',
				tuijian: ''
			};
		},
		onLoad(options) {
			this.type = options.type
			this.status = options.status
			this.tuijian = options.tuijian
			this.title = options.title
			this.queryList(1)
		},
		methods: {
			keywordClear(event) {
				this.$refs.paging.reload(false);
			},
			keywordCustom(event) {
				this.$refs.paging.reload(false);
			},
			queryList(pageNo) {
				this.$api
					.apiHouseList({
						page: pageNo,
						keyword: this.keyword,
						type: this.type ? this.type : '',
						status: this.status ? this.status : '',
						tuijian: this.tuijian ? this.tuijian : ''
					})
					.then((res) => {
						this.$refs.paging.complete(res.house_list);
					});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.app-container {
		.search-item {
			padding: 20rpx 30rpx;
		}

		.pop-box {
			padding: 60rpx 30rpx 0;
			width: 480rpx;

			.tab {
				flex-wrap: wrap;

				.item {
					margin-right: 20rpx;
					margin-bottom: 20rpx;

					/deep/ .u-tag {
						justify-content: center;
					}
				}
			}
		}

		.tabs {
			margin-top: 35rpx;

			/deep/ .u-text {
				flex: none;
				width: auto;
			}
		}
	}
</style>